import { MigrationInterface, QueryRunner } from "typeorm";

export class InitManyToOne1733033322999 implements MigrationInterface {
    name = 'InitManyToOne1733033322999'

    public async up(queryRunner: QueryRunner): Promise<void> {
        await queryRunner.query(`CREATE TABLE "sample_many_to_one_photo" ("id" SERIAL NOT NULL, "url" character varying NOT NULL, "userId" integer, CONSTRAINT "PK_50fd19b092e403c7f429e967baf" PRIMARY KEY ("id"))`);
        await queryRunner.query(`CREATE TABLE "sample_many_to_one_user" ("id" SERIAL NOT NULL, "name" character varying NOT NULL, CONSTRAINT "PK_4eed08b494fb86fd9b377a08d7c" PRIMARY KEY ("id"))`);
        await queryRunner.query(`ALTER TABLE "sample_many_to_one_photo" ADD CONSTRAINT "FK_535d860a8374a60f04a265551e1" FOREIGN KEY ("userId") REFERENCES "sample_many_to_one_user"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`);
    }

    public async down(queryRunner: QueryRunner): Promise<void> {
        await queryRunner.query(`ALTER TABLE "sample_many_to_one_photo" DROP CONSTRAINT "FK_535d860a8374a60f04a265551e1"`);
        await queryRunner.query(`DROP TABLE "sample_many_to_one_user"`);
        await queryRunner.query(`DROP TABLE "sample_many_to_one_photo"`);
    }

}
